/*
 * @lc app=leetcode.cn id=1688 lang=typescript
 *
 * [1688] 比赛中的配对次数
 */

// @lc code=start
function numberOfMatches(n: number): number {
    let count = 0;
    let now = n;
    let last = 0;
    while (now >= 1) {
        now += last;
        last = now % 2;
        now = Math.floor(now / 2);
        count += now;
    }
    return count;
}
// @lc code=end
